home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 103
/
Vol 103.iso
/
games
/
starship.swf
/
scripts
/
DefineSprite_34
/
frame_3
/
DoAction.as
Wrap
Text File
|
2010-03-13
|
3KB
|
153 lines
actSpeed = 0;
vx *= _root.cst.slowdown;
collision = 0;
legL = false;
legR = false;
legC = false;
if(_parent.matter.platform.hitTest(_X + sensorX[0],_Y + sensorY[0],true))
{
collision++;
legL = true;
}
if(_parent.matter.platform.hitTest(_X + sensorX[1],_Y + sensorY[1],true))
{
collision++;
legR = true;
}
if(_parent.matter.platform.hitTest(_X + sensorX[2],_Y + sensorY[2],true))
{
collision++;
legC = true;
}
if(legL == true && legR != true)
{
if(_parent.matter.platform.hitTest(_X + sensorX[1],_Y + sensorY[1] + 3.5,true))
{
rotate = 2;
maxrotate = 5;
}
else
{
rotate = 3;
maxrotate = 10;
}
}
if(legR == true && legL != true)
{
if(_parent.matter.platform.hitTest(_X + sensorX[0],_Y + sensorY[0] + 3.5,true))
{
rotate = -2;
maxrotate = 5;
}
else
{
rotate = -3;
maxrotate = 10;
}
}
if(legL != true && legR != true)
{
rotate = 0;
}
if(1 < collision)
{
ground = true;
fireLeft.gotoAndStop("inactive");
fireRight.gotoAndStop("inactive");
vy = 0;
vx = 0;
if(Math.abs(_rotation) < maxrotate && rotate != 0)
{
_rotation = _rotation + rotate;
_Y = _Y + 0.2;
}
i = 5;
while(6 >= i)
{
bump();
i++;
}
}
else
{
ground = false;
_rotation = _rotation * 0.9;
vy += _root.cst.gravity;
}
completeCollisionCheck();
if(collision == true)
{
collision = false;
i = 5;
while(9 >= i)
{
if(_parent.matter.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
{
bump();
}
i++;
}
}
checkBorderCollision();
if(Key.isDown(Key.UP))
{
vy += ay;
fireDown.gotoAndStop("fire");
}
else
{
fireDown.gotoAndStop("inactive");
}
if(Key.isDown(Key.LEFT))
{
if(ground == true)
{
vy += ay;
}
vx -= ax;
fireRight.gotoAndStop("fire");
_rotation = _rotation * 0.98 + 1;
shootLeft = true;
}
else
{
fireRight.gotoAndStop("inactive");
}
if(Key.isDown(Key.RIGHT))
{
if(ground == true)
{
vy += ay;
}
vx += ax;
fireLeft.gotoAndStop("fire");
_rotation = _rotation * 0.98 - 1;
shootLeft = false;
}
else
{
fireLeft.gotoAndStop("inactive");
}
_X = _X + vx;
_Y = _Y + vy;
if(Key.isDown(Key.SPACE))
{
if(_parent.shot.ready == true)
{
if(shootLeft != true)
{
_parent.shot._x = _X + 15;
_parent.shot._y = _Y - 8;
_parent.shot.vx = 3;
}
else
{
_parent.shot._x = _X - 15;
_parent.shot._y = _Y - 8;
_parent.shot.vx = -3;
}
_parent.shot.ready = false;
_parent.shot.gotoAndPlay("shoot");
}
}